<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ajax promise</title>
</head>
<body>
    <button id="btn">click</button>
    <textarea name="" id="text" cols="30" rows="10"></textarea>

    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

    <script>
        function show () {
            console.log('jsonp is p');
        }
    
        function getData (url) {
            return new Promise((resolve, reject) => {
                
                $.ajax({
                    url: url,
                    dataType: 'jsonp',
                    type: 'GET',
                    jsonpCallback: 'window.baidu.sug',
                    success (data) {
                        reject(data)
                    },
                    error (err) {
                        reject(err)
                    }
                })

            });
        }


        getData('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su').then(res=>{
            console.log(res);
        },err=>{
            console.log(err);
        })
    
    </script>
</body>
</html>